# Maintainer: Sven-Hendrik Haase <svenstaro@archlinux.org>
# Contributor: Arkham <arkham at archlinux dot us>
# Contributor: Christoph Zeiler <archNOSPAM_at_moonblade.dot.org>

pkgname=spring
pkgver=106.0
pkgrel=2
pkgdesc='A free 3D real-time-strategy (RTS) game engine'
arch=('loong64' 'x86_64')
url="http://springrts.com/"
license=('GPL')
depends=('openal' 'glew' 'minizip' 'freetype2' 'devil' 'libvorbis' 'sdl2' 'libunwind'
         'libxcursor' 'curl' 'shared-mime-info' 'desktop-file-utils' 'libx11' 'jsoncpp')
makedepends=('cmake' 'zip' 'xz' 'p7zip' 'python' 'jdk8-openjdk' 'mesa')
optdepends=('python: python-based bots'
            'java-runtime: java-based bots')
source=("https://springrts.com/dl/buildbot/default/master/106.0/source/spring_106.0_src.tar.gz"
         spring-gcc12.patch)
sha512sums=('d76bec4cc106ed23f09699d702b9d14b76e32f4e34beac2313268c2ef29f6379a970efaee209d4db5dc7c6323d1a47882b10c5c4faa0744087fada227ed91f7b'
            '68bbffe545fe5200ab7273954a1aad7fdc67ba904a0a3d86f9fb6b02cd2e716ab9623da8b8bf92c1efda269b161ee28432aa7e0f8899ad914491648fae13e34a')

prepare() {
  cd spring_$pkgver

  patch -Np1 -i ../spring-gcc12.patch
  #remove bundled libraries
  rm -r tools/pr-downloader/src/lib/jsoncpp
  rm -r tools/pr-downloader/src/lib/minizip
}

build() {
  cd spring_$pkgver

  cmake	\
    -Bbuild \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DDATADIR=share/spring \
    -DJAVA_HOME=/usr/lib/jvm/java-8-openjdk \
    -DCMAKE_SKIP_RPATH=ON \
    -DPRD_JSONCPP_INTERNAL=OFF
  make -C build
}

package() {
  cd spring_$pkgver

  DESTDIR="$pkgdir" make -C build install

  install -d "$pkgdir/etc/spring"
  echo '$HOME/.spring' > "$pkgdir/etc/spring/datadir"
}

# vim sw=2:ts=2 et:
